home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / graphics / picfmts.doc < prev    next >
Encoding:
Text File  |  1995-04-22  |  42.4 KB  |  1,090 lines

  1.                            ST Picture Formats
  2.                            ------------------
  3.                                Edited by:
  4.  
  5.                               David Baggett
  6.                          5640 Vantage Point Road
  7.                          Columbia, MD  21044 USA
  8.                              (301)  596-4779    
  9.  
  10.                                 Internet:
  11.                              dmb@wam.umd.edu 
  12.                                dmb@tis.com
  13.  
  14.                    (Please report errors or additions.)
  15.  
  16.         Copyright (C) 1988, 1989, 1990, 1991 by David M. Baggett
  17.  
  18.  
  19.     Non-profit redistribution of this document is permitted, provided
  20.     the document is not modified in any way.
  21.  
  22.     Reproduction of this document in whole or in part for  commercial
  23.     purposes is expressly forbidden without the prior written consent
  24.     of David M. Baggett.
  25.  
  26.     The  information  presented here is not guaranteed to be correct.
  27.     The editor and contributors will in no event be liable for direct,
  28.     indirect, incidental, or consequential damages resulting from the 
  29.     use of the information in this document.
  30.  
  31.     This document is the product of many hours of volunteer work by a
  32.     large number of people. Please respect this -- do not violate the
  33.     distribution policy.
  34.  
  35.  
  36.                               CONTRIBUTORS
  37.   
  38.     Steve Belczyk  Phil Blanchfield  Jason Blochowiak  John Brochu**
  39.         David Brooks  Daniel Deimert  Neil Forsyth  Stefan Hoehn  
  40.     Gerfried Klein  G. "Maddog" Knauss  Ken MacLeod  Shamus McBride
  41.          Jim McCabe  Lars Michael  Darek Mihocka  David Mumper
  42.            George Nassas  Jim Omura  George Seto  Joe Smith
  43.               Greg Wageman  Roland Waldi*  Gerry Wheeler
  44.  
  45.  
  46.                                 Contents 
  47.                                 --------
  48.  
  49.         NEOchrome                               *.NEO
  50.         NEOchrome Animation                     *.ANI
  51.         DEGAS                                   *.PI?   ? = 1, 2, 3
  52.         DEGAS Elite                             *.PI?   ? = 1, 2, 3
  53.         DEGAS Elite (Compressed)                *.PC?   ? = 1, 2, 3
  54.         Tiny                                    *.TN?   ? = 1, 2, 3, Y
  55.         Spectrum 512                            *.SPU
  56.         Spectrum 512 (Compressed)               *.SPC
  57.         Spectrum 512 (Smooshed)                 *.SPS
  58.         Art Director                            *.ART
  59.         C.O.L.R. Object Editor Mural            *.MUR
  60.         Doodle                                  *.DOO
  61.         Cyber Paint Sequence                    *.SEQ
  62.         Animatic Film                           *.FLM
  63.         Animaster Sprite Bank                   *.ASB
  64.         STOS                                    *.MBK
  65.         GEM Bit Image                           *.IMG
  66.         STAD                                    *.PAC
  67.         Imagic Film/Picture                     *.IC?   ? = 1, 2, 3
  68.         IFF                                     *.IFF
  69.         RGB Intermediate Format                 *.RGB
  70.         ComputerEyes Raw Data Format            *.CE?   ? = 1, 2
  71.         MacPaint                                *.MAC
  72.         PackBits Compression Algorithm
  73.  
  74.  
  75.                         Introductory Information
  76.                         ------------------------
  77. word    = 2 bytes
  78. long    = 4 bytes
  79. palette = Hardware color palette, stored as 16 words.  First word is
  80.           color register zero (background), last word is color register
  81.           15.  Each word has the form:
  82.  
  83.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  84.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  85.                        0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0
  86.  
  87.           R2 = MSB of red intensity
  88.           R0 = LSB of red intensity
  89.  
  90.           G2 = MSB of green intensity
  91.           G0 = LSB of green intensity
  92.  
  93.           B2 = MSB of blue intensity
  94.           B0 = LSB of blue intensity
  95.  
  96.           Intensity ranges from 0 (color not present) to 7 (highest
  97.           intensity).
  98.  
  99.           Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)
  100.  
  101.           Caveat:  It is wise to mask off the upper four bits of each
  102.                    palette entry, since a few programs store special
  103.                    information there (most notably Art Studio).
  104.  
  105.  
  106.                              The Formats
  107.                              -----------
  108.  
  109. <NEOchrome>     *.NEO
  110.  
  111. 1 word          flag byte [always 0]
  112. 1 word          resolution [0 = low res, 1 = medium res, 2 = high res]
  113. 16 words        palette
  114. 12 bytes        filename [usually "        .   "]
  115. 1 word          color animation limits.  High bit (bit 15) set if color
  116.                 animation data is valid.  Low byte contains color animation
  117.                 limits (4 most significant bits are left/lower limit,
  118.                 4 least significant bits are right/upper limit).
  119. 1 word          color animation speed and direction.  High bit (bit 15) set
  120.                 if animation is on.  Low order byte is # vblanks per step.
  121.                 If negative, scroll is left (decreasing).  Number of vblanks
  122.                 between cycles is |x| - 1
  123. 1 word          # of color steps (as defined in previous word) to display
  124.                 picture before going to the next.  (For use in slide shows)
  125. 1 word          image X offset [unused, always 0]
  126. 1 word          image Y offset [unused, always 0]
  127. 1 word          image width [unused, always 320]
  128. 1 word          image height [unused, always 200]
  129. 33 words        reserved for future expansion
  130. 16000 words     picture data (screen memory)
  131. -----------
  132. 32128 bytes     total
  133.  
  134.  
  135. <NEOchrome Animation>        *.ANI
  136.  
  137. NOTE:      To get this feature on versions 0.9 and later select the Grabber
  138.         icon and click both mouse buttons in the eye of the second R in the
  139.         word GRABBER.
  140.            Interestingly enough, some versions of NEO only require you
  141.         to press the right button, not both.  Hmmm...
  142.  
  143. 1 long          magic number BABEEBEA (hex) (seems to be ignored)
  144. 1 word          width of image in bytes (always divisible by 8)
  145. 1 word          height of image in scan lines
  146. 1 word          size of image in bytes + 10 (!)
  147. 1 word          x coordinate of image (must be divisible by 16) - 1
  148. 1 word          y coordinate of image - 1
  149. 1 word          number of frames
  150. 1 word          animation speed (# vblanks to delay between frames)
  151. 1 long          reserved; should be zero
  152. --------
  153. 22 bytes        total for header
  154.  
  155. ? words         image data (words of screen memory) for each frame, in 
  156.                 order
  157.  
  158.  
  159. <DEGAS>         *.PI1 (low resolution)
  160.                 *.PI2 (medium resolution)
  161.                 *.PI3 (high resolution)
  162.  
  163. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  164.                 Other bits may be used in the future; use a simple bit
  165.                 test rather than checking for specific word values.
  166. 16 words        palette
  167. 16000 words     picture data (screen memory)
  168. -----------
  169. 32034 bytes     total
  170.  
  171.  
  172. <DEGAS Elite>   *.PI1 (low resolution)
  173.                 *.PI2 (medium resolution)
  174.                 *.PI3 (high resolution)
  175.  
  176. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  177.                 Other bits may be used in the future; use a simple bit
  178.                 test rather than checking for specific word values.
  179. 16 words        palette
  180. 16000 words     picture data (screen memory)
  181. 4 words         left color animtion limit table (starting color numbers)
  182. 4 words         right color animation limit table (ending color numbers)
  183. 4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
  184. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  185.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  186. -----------
  187. 32066 bytes     total
  188.  
  189.  
  190. <DEGAS Elite (Compressed)>      *.PC1 (low resolution)
  191.                                 *.PC2 (medium resolution)
  192.                                 *.PC3 (high resolution)
  193.  
  194. 1 word          resolution (same as Degas, but high order bit is set;
  195.                 i.e., hex 8000 = low res, hex 8001 = medium res,
  196.                 hex 8002 = high res).  Other bits may be used in the
  197.                 future; use a simple bit test rather than checking
  198.                 for specific word values.
  199. 16 words        palette
  200. < 32000 bytes   control/data bytes
  201. 4 words         left color animation limit table (starting color numbers)
  202. 4 words         right color animation limit table (ending color numbers)
  203. 4 words         animation channel direction flag [0 = left, 1 = off, 2 = right]
  204. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  205.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  206. -----------
  207. < 32066 bytes   total
  208.  
  209. Compression Scheme:
  210.  
  211.    PackBits compression is used (see below).  Each scan line is compressed
  212. separately; i.e., all data for a given scan line appears before any data
  213. for the next scan line.  The scan lines are specified from top to bottom
  214. (i.e., 0 is first).  For each scan line, all the data for a given bit plane
  215. appears before any data for the next higher order bit plane.  Note that this
  216. is identical to the IFF 'BODY' image data.
  217.    To clarify:  The first data in the file will be the data for the lowest
  218. order bit plane of scan line zero, followed by the data for the next higher
  219. order bit plane of scan line zero, etc., until all bit planes have been
  220. specified for scan line zero.  The next data in the file will be the data
  221. for the lowest order bit plane of scan line one, followed by the data for
  222. the next higher order bit plane of scan line one, etc., until all bit planes
  223. have been specified for all scan lines.
  224.  
  225. Caveats:
  226.  
  227.    DEGAS Elite's picture loading routine places some restrictions on
  228. compressed DEGAS files:
  229.  
  230.         o Elite uses a 40-byte buffer to store data being decompressed.
  231.  
  232.         o Whenever a control command is encountered, bytes are stuffed
  233.         in this buffer.
  234.  
  235.         o The buffer is only emptied when there are EXACTLY 40
  236.         characters in it.
  237.  
  238. The important conclusion here is that
  239.  
  240.         No control command may cause the buffer to have more than 40
  241.         bytes in it.  In other words, all control commands must end on
  242.         or before the 40-byte boundary.
  243.  
  244. Any picture violating the last condition will cause Elite to get a bus
  245. error when the picture is loaded.
  246.  
  247.  
  248. <Tiny>  *.TNY (any resolution)
  249.         *.TN1 (low resolution)
  250.         *.TN2 (medium resolution)
  251.         *.TN3 (high resolution)
  252.  
  253.    Several people have reported sightings of mutated Tiny pictures that
  254. do not follow the standard format, so let's be careful out there.  What
  255. is described here is the format that David Mumper's original
  256. TNYSTUFF.PRG produces.
  257.  
  258. 1 byte          resolution (same as NEO, but +3 indicates rotation
  259.                 information also follows)
  260.  
  261. If resolution > 2 {
  262. 1 byte          left and right color animation limits.  High 4 bits
  263.                 hold left (start) limit; low 4 bits hold right (end) limit
  264. 1 byte          direction and speed of color animation (negative value
  265.                 indicates left, positive indicates right, absolute value
  266.                 is delay in 1/60's of a second.
  267. 1 word          color rotation duration (number of iterations)
  268. }
  269.  
  270. 16 words        palette
  271. 1 word          number of control bytes
  272. 1 word          number of data words
  273. 3-10667 bytes   control bytes
  274. 1-16000 words   data words
  275. -------------
  276. 42-32044 bytes  total
  277.  
  278. Control byte meanings:
  279.  
  280.         For a given control byte, x:
  281.  
  282.         x < 0   Absolute value specifies the number of unique words to
  283.                 take from the data section (from 1 to 127)
  284.         x = 0   1 word is taken from the control section which specifies
  285.                 the number of times to repeat the next data word (from
  286.                 128 to 32767)
  287.         x = 1   1 word is taken from the control section which specifies
  288.                 the number of unique words to be taken from the data
  289.                 section (from 128 - 32767)
  290.         x > 1   Specifies the number of times to repeat the next word
  291.                 taken from the data section (from 2 to 127)
  292.  
  293. Format of expanded data:
  294.  
  295.    The expanded data is not simply screen memory bitmap data; instead, the 
  296. data is divided into four sets of vertical columns.  (This results in
  297. better compression.)  A column consists of one specific word taken
  298. from each scan line, going from top to bottom.  For example, column 1 
  299. consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
  300. followed by word 1 on scanline 200.
  301.    The columns appear in the following order:
  302.  
  303.    1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
  304.    2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
  305.    3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
  306.    4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
  307.  
  308. Note that Tiny partitions the screen this way regardless of resolution; i.e., 
  309. these aren't bitplanes.  For example, medium resoltion only has two bitplanes, 
  310. but Tiny still divides medium resolution pictures into four parts.
  311.  
  312.  
  313. <Spectrum 512>  *.SPU
  314.  
  315. 80 words        first scan line of picture (unused) -- should be zeroes
  316. 15920 words     picture data (screen memory) for scan lines 1 through 199
  317. 9552 words      3 palettes for each scan line (the top scan line is
  318.                 not included because Spectrum 512 can't display it)
  319. -----------
  320. 51104 bytes     total
  321.  
  322. Note that the Spectrum 512 mode's three palette changes per scan
  323. line allow more colors on the screen than normally possible, but a
  324. tremendous amount of CPU time is required to maintain the image.
  325.  
  326. The Spectrum format specifies a palette of 48 colors for each scan line.
  327. To decode a Spectrum picture, one must be know which of these 48 colors
  328. are in effect for a given horizontal pixel position.
  329.  
  330. Given an x-coordinate (from 0 to 319) and a color index (from 0 to 15),
  331. the following C function will return the proper index into the Spectrum
  332. palette (from 0 to 47):
  333.  
  334. /*
  335.  *  Given an x-coordinate and a color index, returns the corresponding
  336.  *  Spectrum palette index.
  337.  *
  338.  *  by Steve Belczyk; placed in the public domain December, 1990.
  339.  */
  340. int 
  341. FindIndex(x, c)
  342.     int x, c;
  343. {
  344.     int x1;
  345.  
  346.     x1 = 10 * c;
  347.  
  348.     if (1 & c)        /* If c is odd */
  349.         x1 = x1 - 5;
  350.     else            /* If c is even */
  351.         x1 = x1 + 1;
  352.  
  353.     if (x >= x1 && x < x1 + 160) 
  354.         c = c + 16;
  355.     else if (x >= x1 + 160) 
  356.         c = c + 32;
  357.  
  358.     return c;
  359. }
  360.  
  361.  
  362. <Spectrum 512 (Compressed)>        *.SPC
  363.  
  364. 1 word          flag word [$5350 or "SP"]
  365. 1 word          reserved for future use [always 0]
  366. 1 long          length of data bit map
  367. 1 long          length of color bit map
  368. <= 32092 bytes  compressed data bit map
  369. <= 17910 bytes  compressed color bit map
  370. --------------
  371. <= 50014 bytes  total
  372.  
  373. Data compression:
  374.  
  375.    Compression is via a modified run length encoding (RLE) scheme,
  376. similar to DEGAS compressed and Tiny.  The data map is stored as a
  377. sequence of records.  Each record consists of a header byte followed by
  378. one or more data bytes.  The meaning of the header byte is as follows:
  379.  
  380.         For a given header byte, x:
  381.  
  382.            0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
  383.         -128 <= x <=  -1   Use the next byte -x + 2 times
  384.  
  385. The data appears in the following order:
  386.  
  387.         1. Picture data, bit plane 0, scan lines 1 - 199
  388.         2. Picture data, bit plane 1, scan lines 1 - 199
  389.         3. Picture data, bit plane 2, scan lines 1 - 199
  390.         4. Picture data, bit plane 3, scan lines 1 - 199
  391.  
  392. Decompression of data ends when 31840 data bytes have been used.
  393.  
  394. Color map compression:
  395.  
  396.    Each 16-word palette is compressed separately.  There are three
  397. palettes for each scan line (597 total).  The color map is stored as a
  398. sequence of records.  Each record starts with a 1-word bit vector which
  399. specifies which of the 16 palette entries are included in the data
  400. following the bit vector (1 = included, 0 = not included).  If a palette
  401. entry is not included, it is assumed to be zero (black).  The least
  402. significant bit of the bit vector refers to palette entry zero, while the
  403. most significant bit refers to palette entry 15.  Bit 15 must be zero,
  404. since Spectrum 512 does not use palette entry 15.  Bit 0 should also be
  405. zero, since Spectrum 512 always makes the background color black.
  406.    The words specifying the values for the palette entries indicated in
  407. the bit vector follow the bit vector itself, in order (0 - 15).
  408.  
  409. NOTE:   Regarding Spectrum pictures, Shamus McBride reports the following:
  410.  
  411.         "... [The Picture Formats List] says bit 15 of the color map vector
  412.         must be zero. I've encountered quite a few files where [bit 15] is 
  413.         set (with no associated palette entry)..."
  414.  
  415.  
  416. <Spectrum 512 (Smooshed)>          *.SPS
  417.  
  418.    This format compresses Spectrum 512 pictures better than the standard
  419. method.  There are at least two programs that support this format, SPSLIDEX
  420. and ANISPEC, although the two seem to differ slightly in their interpretation
  421. of the format.
  422.    One point of interest: Shamus McBride deciphered this format without an ST!
  423.  
  424. 1 word          5350 (hex) ("SP")
  425. 1 word          0 (reserved for future use)
  426. 1 long          length of data bit map
  427. 1 long          length of color bit map
  428. <= ? bytes      compressed data bit map
  429. <= ? bytes      compressed color bit map
  430. ----------
  431. < ?  bytes      total
  432.  
  433. Data compression:
  434.  
  435.    Compression is via a modified run length encoding (RLE) scheme,
  436. similar to that used in Spectrum Compressed (*.SPC) pictures.
  437.  
  438. The data map is stored as a sequence of records.  Each record consists of a
  439. header byte followed by one or more data bytes.  The meaning of the header
  440. byte is as follows:
  441.  
  442.         For a given header byte, x (unsigned):
  443.  
  444.           0 <= x <= 127    Use the next byte x + 3 times
  445.         128 <= x <= 255    Use the next x - 128 + 1 bytes literally
  446.                            (no repetition)
  447.  
  448. There are two kinds of *.SPS files.
  449.  
  450. The data may appear in the same order as *.SPC files (SPSLIDEX format?):
  451.  
  452.         1. Picture data, bit plane 0, scan lines 1 - 199
  453.         2. Picture data, bit plane 1, scan lines 1 - 199
  454.         3. Picture data, bit plane 2, scan lines 1 - 199
  455.         4. Picture data, bit plane 3, scan lines 1 - 199
  456.  
  457. The second variant (ANISPEC format?) encodes the data as byte wide vertical
  458. strips:
  459.  
  460.         Picture data, bit plane 0, scan line   1, columns   0 -   7.
  461.         Picture data, bit plane 0, scan line   2, columns   0 -   7.
  462.         Picture data, bit plane 0, scan line   3, columns   0 -   7.
  463.         . . .
  464.         Picture data, bit plane 0, scan line 199, columns   0 -   7.
  465.         Picture data, bit plane 0, scan line   1, columns   8 -  15.
  466.         Picture data, bit plane 0, scan line   2, columns   8 -  15.
  467.         . . .
  468.         Picture data, bit plane 0, scan line 199, columns 312 - 319.
  469.         Picture data, bit plane 1, scan line   1, columns   0 -   7.
  470.         . . .
  471.         Picture data, bit plane 3, scan line 198, columns 312 - 319
  472.         Picture data, bit plane 3, scan line 199, columns 312 - 319.
  473.  
  474. A for loop to process that data would look like
  475.  
  476.         for (plane = 0; plane < 4; plane++)
  477.             for (x = 0; x < 320; x += 8)
  478.                 for (y = 1; y < 200; y++)
  479.                     for (x1 = 0; x1 < 8; x1++)
  480.                         image[y, x + x1] = ...
  481.  
  482. Color map compression:
  483.  
  484.    Color map compression is similar to *.SPC color map compression, but
  485. the map is compressed as a string of bits, rather than words.  There are
  486. 597 records (one for each palette). Each record is composed of a 14-bit
  487. header followed by a number of 9-bit palette entries.  The 14-bit header
  488. specifies which palette entries follow (1 = included, 0 = not included).
  489. The most significant bit of the header refers to palette entry 1, while
  490. the least significant bit refers to palette 14.  Palette entries 0 and 15
  491. are forced to black (zero).  Each palette entry is encoded as "rrrgggbbb".
  492.  
  493. The format of the palette is described above in the section on uncompressed
  494. Spectrum pictures (*.SPU).
  495.  
  496.  
  497. <Art Director>  *.ART (low resolution only)
  498.  
  499. 16000 words     picture data (screen memory)
  500. 16 words        palette
  501. 15 * 16 words   15 more palettes for animation
  502. -------------
  503. 32512 bytes     total
  504.  
  505.  
  506. <C.O.L.R. Object Editor Mural>        *.MUR (low resolution only)
  507.  
  508. 16000 words     picture data (screen memory)
  509.                 (palettes are stored in separate files)
  510. -----------
  511. 32000 bytes     total
  512.  
  513.  
  514. <Doodle>        *.DOO (high resolution only)
  515.  
  516. 16000 words     picture data (screen memory)
  517. -----------
  518. 32000 bytes     total
  519.  
  520.  
  521. <Cyber Paint Sequence>  *.SEQ (low resolution only)
  522.  
  523.    This format, while fairly complex, yields excellent compression of animated
  524. images while offering reasonably fast decompression times.
  525.  
  526. 1 word          magic number [$FEDB or $FEDC]
  527. 1 word          version number
  528. 1 long          number of frames
  529. 1 word          speed (high byte is vblanks per frame)
  530. 118 bytes       reserved
  531. ---------
  532. 128 bytes       total for .SEQ header
  533.  
  534. for each frame {
  535. 1 word          type (ignored?)
  536. 1 word          resolution [always 0]
  537. 16 words        palette
  538. 12 bytes        filename [usually "        .   "]
  539. 1 word          color animation limits [not used]
  540. 1 word          color animation speed and direction [not used]
  541. 1 word          number of color steps [not used]
  542. 1 word          x offset for this frame [0 - 319]
  543. 1 word          y offset for this frame [0 - 199]
  544. 1 word          width of this frame, in pixels (may be 0, see below)
  545. 1 word          height of this frame, in pixels (may be 0, see below)
  546. 1 byte          operation [0 = copy, 1 = exclusive or]
  547. 1 byte          storage method [0 = uncompressed, 1 = compressed]
  548. 1 long          length of data in bytes (if the data is compressed, this
  549.                 will be the size of the compressed data BEFORE decompression)
  550. 60 bytes        reserved                
  551. --------
  552. 128 bytes       total for frame header
  553.  
  554. ? bytes         data
  555. }
  556.  
  557.    Frames are "delta-compressed," meaning that only the changes from one
  558. frame to the next are stored.  On the ST, .SEQ files are always full-screen
  559. low resolution animations, so the sequence resulting from expanding all the
  560. data will be n 320 by 200 pixel low resolution screens, where n is given in
  561. the .SEQ header.
  562.   
  563.    Since only the changes from frame to frame are stored, image data for a
  564. frame will rarely be 320x200 (except for the very first frame, which will 
  565. always be a full screen).  Instead what is stored is the smallest rectangular
  566. region on the screen that contains all the changes from the previous frame to
  567. the current frame.  The x offset and y offset in the frame header determine
  568. where the upper left corner of the "change box" lies, and the width and height
  569. specify the box's size.
  570.  
  571.    Additionally, each "change box" is stored in one of five ways.  For each
  572.    of these, the screen is assumed to have the full-screen image from the last
  573.    frame on it.
  574.    
  575.    o uncompressed copy:  The data for this frame is uncompressed image data,
  576.      and is simply copied onto the screen at position (x, y) specified
  577.      in the frame header.
  578.  
  579.    o uncompressed eor:  The data for this frame is exclusive or'ed with the
  580.      screen at position (x, y).
  581.  
  582.    o compressed copy:  The data for this frame must be decompressed (see 
  583.      below), and then copied onto the screen at position (x, y) specified
  584.      in the frame header.
  585.  
  586.    o compressed eor:  The data for this frame must be decompressed (see 
  587.      below), and then exclusive or'ed with the screen RAM at position (x, y).
  588.  
  589.    o null frame:  The width and/or height of this frame is 0, so this
  590.      frame is the same as the previous frame.
  591.    
  592.    Of the 5 methods above, the one that results in the smallest amount
  593.    of data being stored for a particular is used for that frame.
  594.   
  595. Compression Scheme:
  596.  
  597.    Compression is similar to that employed by Tiny, but is not quite as
  598. space-efficient.
  599.  
  600. Control word meanings:
  601.  
  602.         For a given control word, x:
  603.  
  604.         x < 0   Absolute value specifies the number of unique words to
  605.                 take from the data section (from 1 to 32767).
  606.         x > 0   Specifies the number of times to repeat the next word
  607.                 taken from the data section (from 1 to 32767).
  608.  
  609.         Note that a control word of 0 is possible but meaningless.
  610.  
  611. Format of expanded data:
  612.  
  613.    The expanded data is not simply screen memory bitmap data; instead the four
  614. bitplanes are separated, and the data within each bitplane is presented
  615. vertically instead of horizontally.  (This results in better compression.)
  616.  
  617.    To clarify, data for a full screen would appear in the following order:
  618.    
  619.    bitplane 0, word 0, scanline 0
  620.    bitplane 0, word 0, scanline 1
  621.    ...
  622.    bitplane 0, word 0, scanline 199
  623.    bitplane 0, word 1, scanline 0
  624.    bitplane 0, word 1, scanline 1
  625.    ...
  626.    bitplane 0, word 1, scanline 199
  627.    ... 
  628.    bitplane 0, word 79, scanline 199
  629.    bitplane 1, word 0, scanline 0
  630.    ... 
  631.    bitplane 3, word 79, scanline 199
  632.  
  633. Note however, that the data does not usually refer to an entire screen, but
  634. rather to the smaller "change box," whose size is given in the frame header.
  635.  
  636.  
  637. <Animatic Film> *.FLM (low resolution only)
  638.  
  639. 1 word          number of frames
  640. 16 words        palette
  641. 1 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
  642. 1 word          direction (0 = forwards, 1 = backwards)
  643. 1 word          end action (what to do after the last frame)
  644.                 0 = pause, then repeat from beginning
  645.                 1 = immediately repeat from beginning
  646.                 2 = reverse (change direction)
  647. 1 word          width of film in pixels
  648. 1 word          height of film in pixels
  649. 1 word          Animatic version number (major) [< 2]
  650. 1 word          Animatic version number (minor)
  651. 1 long          magic number 27182818 (hex)
  652. 3 longs         reserved for expansion (should be all zeros)
  653. --------
  654. 32 words        total for header
  655.  
  656. ? words         image data (words of screen memory) for each frame, in order
  657.  
  658.  
  659. <Animaster Sprite Bank> *.ASB (low resolution only)
  660.  
  661. 1 word          number of frames - 1
  662. 1 word          ?
  663. 1 byte          maximum width, in pixels
  664. 1 byte          maximum height, in pixels
  665. 16 words        palette
  666. --------
  667. 38 bytes        total for header
  668.  
  669. For each frame {
  670. 1 word          width of this frame (in pixels) - 1
  671. 1 word          height of this frame (in pixels) - 1
  672. 1 word          ? 
  673. ? words         image data (words of screen memory)
  674. }
  675.  
  676.  
  677. <STOS>  *.MBK
  678.  
  679. 9 words         ?
  680. 1 long          $19861987 (magic number?)
  681. 1 long          offset from this long to header for low resolution 
  682.                 parameter block (if past end of file, no low res frames)
  683. 1 long          offset from this long to header for med resolution 
  684.                 parameter block (if past end of file, no med res frames)
  685. 1 long          offset from this long to header for high resolution 
  686.                 parameter block (if past end of file, no high res frames)
  687. 1 word          number of low resolution frames
  688. 1 word          number of medium resolution frames
  689. 1 word          number of high resolution frames
  690.  
  691. For each frame {
  692. 1 long          offset to data (probably only used internally by STOS)
  693. 1 byte          width in words (multiply by 16 to get width in pixels)
  694. 1 byte          height in pixels
  695. 1 byte          X hotspot location
  696. 1 byte          Y hotspot location
  697. }
  698.  
  699. (The format implies other stuff could be here.)
  700.  
  701. 1 long          ["PALT" $50414C54]
  702. 16 words        palette
  703.  
  704. ?               words of data for each frame, in the order mentioned in the
  705.                 header.  Monoplanar mask data follows image data for each frame.
  706. ----------
  707. ? words         total
  708.  
  709.    The frames often seem to be in semi-random order, not necessarily in 
  710. the order they are to be animated. 
  711.  
  712.  
  713. <GEM Bit Image> *.IMG
  714.  
  715. 1 word          version number of image file [1]
  716. 1 word          length of header in words [usually 8]
  717. 1 word          number of color planes [1 for monochrome]
  718. 1 word          pattern length in bytes [1-8, usually 2 for screen images]
  719. 1 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
  720. 1 word          pixel height in microns
  721. 1 word          line width in pixels
  722. 1 word          number of lines
  723. -------
  724. ? words         header length defined in 2nd word of header
  725.  
  726. ? bytes         data
  727.  
  728. NOTES:  If the image is a color image (planes > 1), the planes are stored
  729. separately starting with plane 0.  There is, however, no standard way of
  730. storing the color palette.  Some programs may save the palette in separate
  731. files, some may extend the header.  For this reason, you should never
  732. assume the header is 8 words long, always get the header length from the
  733. 2nd word of the header.  Also, the line width in the 7th word is the number
  734. of pixels in a line.  Since the data is encoded in byte-wide packets, the
  735. actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
  736. longer than the length specified in the header.
  737.  
  738. For each byte x in the data section,
  739.  
  740.         x = 0           Pattern/scanline run.
  741.                         Read the next byte, n (unsigned).
  742.  
  743.                         If n > 0 then:
  744.                                 Read a number of bytes equal to the "pattern
  745.                                 length" word in the header.  Repeat this
  746.                                 pattern n times.
  747.  
  748.                         If n = 0 then:
  749.                                 Scanline run.  Data for the next scanline
  750.                                 is to be used multiple times.  Read the
  751.                                 following record:
  752.  
  753.                                 1 byte          flag byte [$FF]
  754.                                 1 byte          number of times to use
  755.                                                 next scanline data
  756.  
  757.                                 The data for the next scanline follows,
  758.                                 compressed normally.
  759.  
  760.         x = 80 (hex)    Uncompressed bit string.  The next byte
  761.                         determines the number of bytes to use
  762.                         literally.  The literal data bytes follow.
  763.  
  764.         otherwise       Solid run.  The value of x determines
  765.                         what to draw.  The high bit specifies whether
  766.                         the pixels are set or cleared.  A 1 indicates
  767.                         a byte-run using $FF, a 0 indicates a byte-run
  768.                         using $00.  The low 7 bits, taken as an unsigned
  769.                         quantity, specify the length of the run in bytes.
  770.  
  771.  
  772. <STAD>          *.PAC (high resolution only)
  773.  
  774. 4 bytes         "pM86" (vertically packed) or "pM85" (horizontally packed)
  775. 1 byte          id byte
  776. 1 byte          pack byte (most frequently occuring byte in bitmap)
  777. 1 byte          "special" byte
  778. -------
  779. 7 bytes         total for header
  780.  
  781. ? bytes         data
  782.  
  783. The data is encoded as follows.  For each byte x in the data section:
  784.  
  785.         x = id byte             Read one more byte, n.  Use pack byte 
  786.                                 n + 1 times.
  787.         x = "special" byte      Read two more bytes, d, and n (in order).
  788.                                 Use byte d n times.
  789.         otherwise               Use byte x literally.
  790.  
  791.  
  792. <Imagic Film/Picture>           *.IC1 (low resolution)
  793.                                 *.IC2 (medium resolution)
  794.                                 *.IC3 (high resolution)
  795.  
  796. 4 bytes         "IMDC"
  797. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  798. 16 words        palette
  799. 1 word          date (GEMDOS format)
  800. 1 word          time (GEMDOS format)
  801. 8 bytes         name of base picture file (for delta compression), or zeroes
  802. 1 word          length of data (?)
  803. 1 long          registration number
  804. 8 bytes         reserved
  805. 1 byte          compressed? (0 = no, 1 = yes)
  806.  
  807. If compressed {
  808. 1 byte          delta-compressed? (-1 = no, > -1 = yes)
  809. 1 byte          ?
  810. 1 byte          escape byte
  811. }
  812. -------
  813. 65 bytes        total for header (68 bytes if compressed)
  814.  
  815. ? bytes         data
  816.  
  817.    Compressed data may be either stand-alone or delta-compressed (relative
  818. to the base picture named in the header).  Delta compression involves
  819. storing only how the picture differs from the base picture (i.e., only
  820. portions of the screen that have changed are stored).  This is used to
  821. to encode animated sequences efficiently.
  822.  
  823. Compressed data, stand-alone:
  824.  
  825. For each byte x in the data section:
  826.  
  827.         x = escape byte         Read one more byte, n.  (n is unsigned).
  828.  
  829.                                 If n >= 2, use the next byte n times.
  830.                                 If n = 1, keep reading bytes until a
  831.                                 byte k not equal to 1 is encountered.
  832.                                 Then read the next byte d.
  833.                                 If the number of 1 bytes encountered is o,
  834.                                 use d (256 * o + k) times.  I.e.,
  835.  
  836.                                 if (n == 1) {
  837.                                         o = 0;
  838.                                         while (n == 1) {
  839.                                                 o++;
  840.                                                 n = next byte;
  841.                                         }
  842.  
  843.                                         k = n;
  844.                                         d = next byte;
  845.  
  846.                                         Use d (256 * o + k) times.
  847.                                 }
  848.                                 else {
  849.                                         d = next byte;
  850.                                         Use d (n) times.
  851.                                 }
  852.  
  853.         x != escape byte        Use x literally.
  854.  
  855. Compressed data, delta compressed:
  856.  
  857. For each byte x in the data section:
  858.  
  859.         x = escape byte         Read one more byte, n.  (n is unsigned).
  860.  
  861.                                 If n >= 3, use the next byte n times.
  862.                                 If n = 1, do the same as for n = 1 in
  863.                                 stand-alone compression (above).
  864.                                 If n = 2, then set n = next byte.
  865.                                         If n = 0, end of picture.
  866.                                         If n >= 2, take n bytes from base
  867.                                         picture.
  868.                                         If n = 1, do the same as for n = 1
  869.                                         in stand-alone compression (above),
  870.                                         but take (256 * o + k) bytes from 
  871.                                         base picture.
  872.  
  873.         x != escape byte        Use x literally.
  874.  
  875.  
  876. <IFF Format>    *.IFF
  877.  
  878. 4 bytes         "FORM" (FORM chunk ID)
  879. 1 long          length of file that follows
  880. 4 bytes         "ILBM" (InterLeaved BitMap file ID)
  881.  
  882. 4 bytes         "BMHD" (BitMap HeaDer chunk ID)
  883. 1 long          length of chunk [20]
  884. 20 bytes        1 word = image width in pixels
  885.                 1 word = image height in lines
  886.                 1 word = image x-offset [usually 0]
  887.                 1 word = image y-offset [usually 0]
  888.                 1 byte = # bitplanes
  889.                 1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso)
  890.                 1 byte = compressed [1] or uncompressed [0]
  891.                 1 byte = unused [0]
  892.                 1 word = transparent color (for mask=2)
  893.                 1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400]
  894.                 1 byte = y-aspect [11]
  895.                 1 word = page width (usually the same as image width)
  896.                 1 word = page height (usually the same as image height)
  897.  
  898. 4 bytes         "CMAP" (ColorMAP chunk ID)
  899. 1 long          length of chunk [3*n where n is the # colors]
  900. 3n bytes        3 bytes per RGB color.  Each color value is a byte
  901.                 and the actual color value is left-justified in the
  902.                 byte such that the most significant bit of the value
  903.                 is the MSB of the byte.  (ie. a color value of 15 ($0F)
  904.                 is stored as $F0)  The bytes are stored in R,G,B order.
  905.  
  906. 4 bytes         "CRNG" (Color RaNGe chunk ID)
  907. 1 long          length of chunk [8]
  908. 8 bytes         1 word = reserved [0]
  909.                 1 word = animation speed (16384 = 60 steps per second)
  910.                 1 word = active [1] or inactive [0]
  911.                 1 byte = left/lower color animation limit
  912.                 1 byte = right/upper color animation limit
  913.  
  914. 4 bytes         "CAMG" (Commodore AMiGa viewport mode chunk ID)
  915. 1 long          length of chunk [4]
  916. 1 long          viewport mode bits (bit 11 = HAM, bit 3 = interlaced)
  917.  
  918. 4 bytes         "BODY" (BODY chunk ID)
  919. 1 long          length of chunk [# bytes of image data that follow]
  920. ? bytes         actual image data
  921.  
  922. NOTES: Some of these chunks may not be present in every IFF file, and may
  923. not be in this order.  You should always look for the ID bytes to find a
  924. certain chunk.  All chunk IDs are followed by a long value that tells the
  925. size of the chunk (note that "ILBM" is not a chunk ID).  This is the number of
  926. bytes that FOLLOW the 4 ID bytes and size longword.  The exception to this is
  927. the FORM chunk.  The size longword that follows the FORM ID is the size of the
  928. remainder of the file.  The FORM chunk must always be the first chunk in an
  929. IFF file.
  930.  
  931. The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7),
  932. as is the maximum number of bitplanes (AMIGA: 5, ST: 4).
  933.  
  934. Format of body data
  935.  
  936. An expanded picture is simply a bitmap.  The packing method is PackBits
  937. (see below), and is identical to MacPaint and DEGAS Elite compressed.
  938.  
  939. The (decompressed) body data appears in the following order:
  940.  
  941.         line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m
  942.         [line 1 mask (if appropriate)]
  943.         line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m
  944.         [line 2 mask (if appropriate)]
  945.         ...
  946.         line x plane 0 ... line x plane 1 ... ... line x plane m
  947.         [line x mask (if appropriate)]
  948.  
  949. The FORM chunk identifies the type of data:
  950.  
  951.         "ILBM" = interleaved bit map
  952.         "8SVX" = 8-bit sample voice
  953.         "SMUS" = simple music score
  954.         "FTXT" = formatted text (Amiga)
  955.  
  956.  
  957. <MacPaint>      *.MAC
  958.  
  959. 1 long          version number [0=ignore header, 2=header valid]
  960. 38 * 8 bytes    8x8 brush/fill patterns.  Each byte is a pattern row,
  961.                 and the bytes map the pattern rows top to bottom.  The
  962.                 patterns are stored in the order they appear at the bottom
  963.                 of the MacPaint screen top to bottom, left to right.
  964. 204 bytes       unused
  965. -------------
  966. 512 bytes       total for header
  967.  
  968. < 51200 bytes   compressed bitmap data
  969. -------------
  970. < 51712 bytes   total
  971.  
  972. NOTE:  The version number is actually a flag to MacPaint to indicate if
  973. the brush/fill patterns are present in the file.  If the version is 0,
  974. the default patterns are used.  Therefore you can simply save a MacPaint
  975. file by writing a blank header (512 $00 bytes), followed by the packed
  976. image data.
  977.  
  978. Bitmap compression:
  979.  
  980.    The bitmap data is for a 576 pixel by 720 pixel monochrome image.
  981. The packing method is PackBits (see below).  There are 72 bytes per
  982. scan line.  Each bit represents one pixel; 0 = white, 1 = black.
  983.  
  984.  
  985. <RGB Intermediate Format>       *.RGB (low resolution only)
  986.  
  987.    This format was invented by Lars Michael to facilitate conversions between
  988. standard ST picture formats and higher resolution formats like GIF and IFF.
  989. It supports 12 bits of color resolution by keeping the red, green and blue
  990. components in separate bit planes.
  991.  
  992. 1 word          resolution (ignored)
  993. 16 word         palette (ignored)
  994. 16000 words     red plane (screen memory)
  995. 1 word          resolution (ignored)
  996. 16 word         palette (ignored)
  997. 16000 words     green plane (screen memory)
  998. 1 word          resolution (ignored)
  999. 16 word         palette (ignored)
  1000. 16000 words     blue plane (screen memory)
  1001. ------------
  1002. 96102 bytes     total
  1003.  
  1004. The format was derived by concatenating three DEGAS .PI1 files together -- 
  1005. one for each color gun.  The RGB value for a pixel is constructed by looking
  1006. at the appropriate pixel in the red plane, green plane, and blue plane.  The
  1007. bitplanes are in standard ST low resolution screen RAM format, but where pixel
  1008. values in screen RAM refer to palette entries (0 through 15), pixel values
  1009. here correspond to absolute R, G, and B values.  The red, green, and blue
  1010. components for each pixel range from 0 to 15 (4 bits), yielding a total of
  1011. 12 bits of color information per pixel.  Not coincidentally, this is exactly
  1012. the format of ST palette entries (although on ST's without the extended 
  1013. palette only the lower 3 bits of each color component are used).
  1014.  
  1015. You can view a single bit plane on a standard ST by splitting the .RGB file
  1016. into its three DEGAS .PI1 components and setting the palette to successively
  1017. brighter shades of gray.
  1018.  
  1019.  
  1020. <ComputerEyes Raw Data Format>  *.CE1 (low resolution)
  1021.                                 *.CE2 (medium resolution)
  1022.                                 
  1023. 1 long          [$45594553 or "EYES"]
  1024. 1 word          resolution [0 = low res, 1 = medium res]
  1025. 8 words         ?
  1026. If resolution = 0 {
  1027. 64000 bytes     red plane, 320 x 200, 1 pixel per byte
  1028. 64000 bytes     green plane, 320 x 200, 1 pixel per byte
  1029. 64000 bytes     blue plane, 320 x 200, 1 pixel per byte
  1030. ------------
  1031. 192022 bytes    total
  1032. else If resolution = 1 {
  1033. 128000 words    640 x 200, 1 pixel per word
  1034. ------------
  1035. 256022 bytes    total
  1036. }
  1037.  
  1038.    This is almost two formats in one:
  1039.    
  1040.         Low resolution:
  1041.  
  1042.            The planes are arranged vertically, instead of horizontally.
  1043.         The first byte is the red component of pixel (0,0), the second is (0,1),
  1044.         and the third (0,2).  The 201st corresponds to (1,0), etc.  The 64001st
  1045.         byte is the green component of (0,0).
  1046.            Only the low six bits of each byte are used.
  1047.  
  1048.         Medium resolution:
  1049.  
  1050.            The picture is arranged vertically, instead of horizontally.
  1051.         The first word is pixel (0,0), the second is (0,1), and the third
  1052.         (0,2).  The 200th is (1,0) etc.
  1053.            Each word is divided up into the RGB values for the corresponding
  1054.         pixel, as follows:
  1055.  
  1056.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  1057.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  1058.                        0 B4 B3 B2 B1 B0 G4 G3 G2 G1 G0 R4 R3 R2 R1 R0
  1059.  
  1060.         Bit 15 is not used.
  1061.  
  1062.  
  1063. <PackBits Compression Algorithm>
  1064.  
  1065. The following packing algorithm originated on the Mac, was adopted by
  1066. Electronic Arts/Commodore for use in the IFF standard, and then by Tom
  1067. Hudson for use in DEGAS Elite.  The algorithm is currently used in
  1068. MacPaint, IFF, and DEGAS Elite compressed file formats.  Each scan line
  1069. is packed separately, and packing never extends beyond a scan line.
  1070.  
  1071. For a given control byte 'n':
  1072.     0 <= n <= 127   : use the next n + 1 bytes literally (no repetition).
  1073.  -127 <= n <= -1    : use the next byte -n + 1 times.
  1074.          n = -128   : no operation, not used.
  1075.  
  1076. -------------------------------------------------------------------------
  1077.  
  1078. * Roland Waldi contributed extensive information on the following formats:
  1079.  
  1080.         GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF
  1081.  
  1082. ** John Brochu, ST picture formats guru, provided sage advice and many
  1083.    corrections to the following formats:
  1084.  
  1085.         NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed,
  1086.         GEM Bit Image, IFF, MacPaint
  1087.  
  1088. Version of Wed Jun 26 22:53:08 EDT 1991
  1089.